unit counterpartiescreateeditgroup;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, DbCtrls,
  StdCtrls, Buttons;

type

  { TfrmCounterPartiesCreateEditGroup }

  TfrmCounterPartiesCreateEditGroup = class(TForm)
    btnCencel: TBitBtn;
    btnGroupSelect: TBitBtn;
    btnSave: TBitBtn;
    DBEdtGroupTitle: TDBEdit;
    edtGroup: TEdit;
    lblGroup: TLabel;
    lblTitle: TLabel;
    procedure btnCencelClick(Sender: TObject);
    procedure btnSaveClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  frmCounterPartiesCreateEditGroup: TfrmCounterPartiesCreateEditGroup;

implementation

{$R *.lfm}
uses main,counterparties;

{ TfrmCounterPartiesCreateEditGroup }

procedure TfrmCounterPartiesCreateEditGroup.btnSaveClick(Sender: TObject);
begin
  if (DBEdtGroupTitle.Text<>'') then begin
    if (edtGroup.Text='') then begin
       frmCounterParties.CurrentGroupRecordNumber:=0;
    end;
    FrmMain.DSCounterPartiesGroup.DataSet.FieldByName('isgroup').AsBoolean:=True;
    FrmMain.DSCounterPartiesGroup.DataSet.FieldByName('parentid').AsInteger:=frmCounterParties.CurrentGroupRecordNumber;
    FrmMain.DSCounterPartiesGroup.DataSet.Post;
    FrmMain.DSCounterParties.DataSet.Refresh;
    FrmMain.DSCounterPartiesGroup.DataSet.Refresh;
    Close;
  end else begin
    ShowMessage('Введіть назву групи');
  end;
end;

procedure TfrmCounterPartiesCreateEditGroup.btnCencelClick(Sender: TObject);
begin
  Close;
end;

end.

